(function(window){
    function Start (){
        //这是第一个事件
        //$('.role_move').hover(
        //
        //    function(){
        //        this.imgOldTop=$('.role_move_img').css('top');
        //        this.imgOldTxt=$('.role_move_txt').css('top');
        //        $('.role_move_img').css('display','block').stop().animate({
        //            top: '-49px'
        //        },200);
        //        $('.role_move_txt').css('display','block').stop().animate({
        //            top: '188px'
        //        },200);
        //    },function(){
        //        $('.role_move_img').css('display','none').animate({
        //            top: this.imgOldTop
        //        },200);
        //        $('.role_move_txt').css('display','none').stop().animate({
        //            top: this.imgOldTxt  #27ae61
        //        },200);
        //    });
        //引入需要的参数
        commonStart('.role_move','.role_move_img','.role_move_txt','-29px','208px','#27ae61');
        commonStart('.role_change_name','.role_change_img','.role_change_txt','-29px','208px','#34495e');
        commonStart('.other_employee_buy','.other_employee_buy_img','.other_employee_buy_txt','-46px','191px','#e94c3d');
        commonStart('.fantasy_medicine','.fantasy_medicine_img','.fantasy_medicine_txt','-43px','205px','#f49c14');
    }
    //将鼠标hover时间封装成函数
    function commonStart(onmouse,imgchange,txtchange,newImgTop,newTxtTop,color){
        $(onmouse).hover(
            function(){
                //预先存好需要的数据
                this.imgOldTop=$(imgchange).css('top');
                this.imgOldTxt=$(txtchange).css('top');
                this.oldMargin=$(this).css('margin');
                //改变图片的样式
                $(onmouse+' img').css('margin','0px');
                $(onmouse+' img').css('border','10px solid '+color);
                $(onmouse+' a .title').css('color',color);
                //$(onmouse).css('border','10px solid '+color);
                //图片进入的动画效果
                $(imgchange).css('display','block').stop().animate({
                    top: newImgTop
                },500);
                $(txtchange).css('display','block').stop().animate({
                    top: newTxtTop
                },500);
            },function(){
                $(onmouse+' img').css('margin','10px');
                $(onmouse+' img').css('border','none');
                $(onmouse+' a .title').css('color','');
                $(imgchange).css('display','none').animate({
                    top: this.imgOldTop
                },200);
                $(txtchange).css('display','none').stop().animate({
                    top: this.imgOldTxt
                },200);
            });
    }
    window.Start=Start;
})(window)